﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Chronos;
public class K_Dash : SkillBase
{
    public RigidbodyTimeline2D rb;
    public float dashSpeedRatio = 1.5f;
    public AnimationEvent animationEvent;

    public override void Init(EntityBase user)
    {
        base.Init(user);
        ColdDownInit();
        rb = User.time.rigidbody2D;
        animationEvent = User.GetComponent<AnimationEvent>();
        animationEvent._event += Stop;

       
    }

    public override void FixedUpdate()
    {
        if(!isColddown)
        {
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                //Debug.Log("Dash");
                rb.velocity = User.parameter.MovementData.moveDir
                            * User.parameter.MovementData.moveSpeed
                            * dashSpeedRatio;
                User.ChangeState(States.K_DashState);
                isColddown = true;
            }

        }
        ColdDownCheck();
    }
    private void Stop()
    {
        //Debug.Log("stop");
        User.ChangeState(States.StandState);
        //rb.velocity = Vector2.zero;
    }
}
